
/**
 * node包：
 * 遵循CommonJS规范： 模块化规范
 * 1. 引入： require()
 * 2. 抛出   modeule.exports = {}  / exports = {}
 */
const fs = require('fs');


// 封装函数

const readFile = (readUrl, writeUrl) => {
  return new Promise((resolve, reject) => {
    fs.readFile(readUrl, (err, data) => {
      const response = fs.writeFileSync(writeUrl, data.toString())
      if (!response) {
        resolve({
          code: 0,
          msg: '写入成功'
        })
      } else {
        reject({
          code: -1,
          msg: '写入失败'
        })
      }
    })
  })
}

module.exports = {
  readFile
}




